﻿using System;
using System.Windows.Forms;
using LiteShared.Dmx_In;

namespace TestApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            ArtEngine.RecievingDMX += new EventHandler(ourDmxReveivedEventFunction);
                       
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ArtEngine.Start();
            timer1.Enabled = true;
            timer1.Start();
        }

        void ourDmxReveivedEventFunction(object sender, EventArgs e)
        {
            DmxInPacket dmxin = (DmxInPacket)sender;
            lastPacketRecvieved = dmxin;

        }

        private ArtNet.Engine ArtEngine = new ArtNet.Engine("LiteMic Testing", "");

        private DmxInPacket lastPacketRecvieved;

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (lastPacketRecvieved != null)
            {
                lblUniverse.Text = Convert.ToString(lastPacketRecvieved.Universe);
                lblProtocol.Text = Convert.ToString(lastPacketRecvieved.Protocol);
                
            }

            byte[] DMXData = new byte[512];
            DMXData[0] = Convert.ToByte(trackBar1.Value);
            DMXData[1] = Convert.ToByte(trackBar2.Value); ;
            DMXData[2] = Convert.ToByte(trackBar3.Value); ;

            ArtEngine.SendDMX(0, DMXData, DMXData.Length);
        }

  

    }
}
